import {
	CalendarExpBarActionType,
	CalendarExpViewActionType,
	IParam,
	ICalendarExpViewAbility,
	ICalendarExpViewController,
	ICalendarExpViewStore,
	ICalendarExpBarAbility,
	ICalendarExpViewControllerParams,
} from '@/core/interface';
import { ExpViewController } from './exp-view-controller';

/**
 * 日历导航视图控制器
 *
 * @export
 * @class CalendarExpViewController
 * @extends {ExpViewController<CalendarExpViewActionType, ICalendarExpViewStore, ICalendarExpViewAbility>}
 * @implements {ICalendarExpViewController<ICalendarExpViewStore, ICalendarExpViewAbility>}
 */
export class CalendarExpViewController
	extends ExpViewController<
		CalendarExpViewActionType,
		ICalendarExpViewStore,
		ICalendarExpViewAbility
	>
	implements
		ICalendarExpViewController<ICalendarExpViewStore, ICalendarExpViewAbility>
{
	/**
	 * 处理视图初始化
	 *
	 * @protected
	 * @param {ICalendarExpViewControllerParams<CalendarExpViewActionType, ICalendarExpViewAbility>} params
	 * @memberof CalendarViewController
	 */
	protected processViewInit(
		params: ICalendarExpViewControllerParams<
			CalendarExpViewActionType,
			ICalendarExpViewAbility
		>
	) {
		super.processViewInit(params);
	}

	/**
	 * 获取日历部件能力
	 *
	 * @protected
	 * @return {*}  {(ICalendarAbility | undefined)}
	 * @memberof CalendarExpViewController
	 */
	protected getMainCtrlAbility(): ICalendarExpBarAbility | undefined {
		const expbar = this.model.ctrls.find(
			(ctrl: IParam) => ctrl.controlType === 'CALENDAREXPBAR'
		);
		return expbar
			? this.getSubAbility<ICalendarExpBarAbility>(expbar.name)
			: undefined;
	}
}
